<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>贷后回访列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<script type="text/javascript">
   var DHHF ="${DHHF}";
	var grid = null;
	$(function () {
		initOrgTree();
	});
	$(function () {
	    $("#ligergrid1").ligerGrid({
	    	 url: '<%=path%>/risk/ovdCollect/LoanLaterinitList.do',
		    	method : 'get',
		        columns: [
		             { display: '承租人', name: 'cstNm', align:'left',minWidth:140,enabledSort:true}, 
		             { display: '合同号', name: 'lsCntNo', minWidth: 140 , enabledSort:true}, 
		             { display: '项目类型', name: 'prjTypCdNm', width: 150, enabledSort:true},
		             { display: '资产数量', name: 'prdQty', minWidth: 100 , enabledSort:true},
		             { display: '所属机构', name: 'buOrgCdNm', width: 100 , enabledSort:true},
		             { display: '省公司', name: 'prOrgCdNm', width: 100 , enabledSort:true},
			         { display: '分公司', name: 'cyOrgCdNm', width: 100 , enabledSort:true},
		             { display: '客户经理', name: 'cstMgrNm', minWidth: 140,align:'center', enabledSort:true},
                     /*{ display: '所属区域', name: 'cstMgrRgnCdNm', minWidth: 140,align:'center', enabledSort:true},*/
		             { display: '合同签署方式', name: 'cntTypCdNm', minWidth: 100 , enabledSort:true},
		             { display: '信审员', name: 'auditorName', minWidth: 150 , 
		            	/*  render:function (rowdata, index, value){
		            		 console.log(rowdata);
		            		 console.log("value"+value);
			            		var g = "";
			            		if(null != rowdata.auditorName){
			            			g = rowdata.auditorName;
			            		}else if(null != value){
			            			g = value;
			            		}
			            		return g;
			            	} */
		             },
		             { display: '审批类型', name:'schr_6', width: 150, enabledSort:true},
		             { display: '回访专员', name:'returnVisitNm', minWidth: 150 , enabledSort:true},
		              { display: '回访时间', name:'lastVisitTm', minWidth: 140 ,render:renderDate, enabledSort:true},
		             /* { display: '回访时间', name: 'crtTm', width: 140, 
	            	      render:function (rowdata, index, value){  
		            		var dateStr = "";
		            		if(StringUtils.isNotEmpty(value)){
		            			var date = new Date(value);
		            			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		            		}
		            		return dateStr;
		            	}
	                 }, */
		             { display: '起租日期', name:'lsDt', minWidth: 140 ,render:renderDate, enabledSort:true},
		             { display: '还款日期', name:'fstRepayDt', minWidth: 140 ,render:renderDate, enabledSort:true},
		             { display: '回访状态', name: 'visitStatus', minWidth: 100 , enabledSort:true},
		             { display: '生成时间', name: 'crtTm', minWidth: 100 , render:renderDate, enabledSort:true},
		             getGridOperColumnContent()
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true,
	        onAfterShowData: function () {
	            $(".gridTip").grid_ligerTip();
	            SetIframe_height ();
	        }
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	    //查询
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	        // console.log(data)
	         data["crtTm"] = $("#crtTm").val();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	    //清空
	    $("#clearBtn").click(function(){
	    	 $("#searchBar").ligerForm();
 			var form = new liger.get("searchBar");
 			//form.clear(); 
 			form.setData({
 				cstNm:" ",
 				lsCntNo:" ",
 				prjTypCd:" ",
 				buOrgCd:" ",
 				cstMgrNm:" ",
 				cntTypCd:" ",
 				auditorName:" ",
 				schr6:" ",//审批类型
 				cstMgrOrgCd:" ",
 			 });
	    })
	   
	});

    function getGridOperColumnContent(){
    	var data = {
                display: '操作',
                isSort: false,
                width: 100,
                align:'left',
                render: function (rowdata, rowindex, value){
                	console.log(rowdata);
                	if(rowdata.lastAuditorName != null){
                		return;
                	}else{
                		 var h="";
                     	h+='<a class="sq-button-hasicon" id="update" href="javascript:modifyRow(';
                         h+="'"+rowdata.id+"',";
                         h+="'"+rowdata.prdTypCd+"',";
                         h+="'"+rowdata.buOrgCd+"'";
                    
                         h+=")\"><i  class=\"sqBtnIco_4\"></i>"+LogUtils.LOG_CMM_GRID_BTN_MODIFY+"</a>"
                     return h;
                	}
                   
                }
        	 }
        	return data;
	}
  //格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	} 
  //修改
  function modifyRow(id,prdTypCd,buOrgCd){
	  //回调页面
	  var callback = function callback() {
		  grid.reload();
	}
	  var DaiHou = "1";
	  var  taskDefKey = "FLOW_00000001_001_003_001";
	    Add_navTab("PrjBscInfo"+id, "修改贷后回访记录", '<%=path%>/risk/ovdCollect/LoanLatertoAddPage.do?projectId='+id+'&prdTypCd='+prdTypCd+'&buOrgCd='+buOrgCd+'&DaiHou='+DaiHou+'&taskDefKey='+taskDefKey,callback); 
  }
  function initOrgTree(){
  	var params = {};
  	 searchOrgTree = $("#cstMgrOrgCd").ligerComboBox({
  		 width: 480,
           selectBoxWidth: 480,
           selectBoxHeight: 150,
           //限制只能选叶节点，父节点不能点击
           treeLeafOnly: false,
           valueField: 'orgCd',
           textField: 'orgDispNm',
           showTreePath: true,
           tree: {
               ajaxType: 'get',
               idFieldName:'orgCd',
               textFieldName: 'orgDispNm',
               checkbox: false,
               parentIcon: "none",
               childIcon: "none",
               needCancel : false
           }
       });
  	 $.ajax({
   		type: 'get',
   		dataType:'json',
   		data: params,
   		url: '<%=path%>/warrant/warrantfilemanage/searchBuOrgTree.do',
   		success:function(msg){
   			if(msg.success == 1){
   				searchOrgTree.treeManager.setData(msg.data);
   				searchOrgTree.clear();
   				searchOrgTree.setValue('${currOrg}');
   			}else{
   				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
   			}
   		}
   	});

  }    
</script>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
           <div class="fieldBox">
                <div class="label">承租人</div>
                <div class="field">
                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox" id="searchLsCntNoId">
                <div class="label">合同号</div>
                <div class="field">
                    <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox">
              <div class="label">项目类型</div>
                <div class="field">
                <select name="prjTypCd"  id="prjTypCd" >
                 <option value="  " selected="selected">--请选择--</option>
                 <c:forEach items="${projectTypeList}" var="opt">
                  <option value="${opt.key}">${opt.value}</option>
                 </c:forEach>
                </select>
                </div>
            </div>
               <div class="fieldBox">
                <div class="label">所属事业部</div>
                <div class="field">
                    <select name="buOrgCd" id="buOrgCd">
                        <option value=" " seleted>--请选择--</option>
                        <c:forEach items="${orgList}" var="org">
                        <option value="${org.key }" >${org.value }</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="fieldBox" id="searchCstNmId" isyw="0">
                <div class="label">客户经理名称</div>
                <div class="field">
                    <input name="cstMgrNm" id="cstMgrNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox" id="searchCntTypCdId">
            <div class="label">合同签署方式</div>
               <div class="field">
                 <select name="cntTypCd"  id="cntTypCd"  >
                  <option value="  " selected="selected">--请选择--</option>
                <c:forEach items="${cntTypCdList}" var="opt">
                 <option value="${opt.key}">${opt.value}</option>
                </c:forEach>
               </select>
               </div>
            </div>
            <div class="fieldBox" id="searchCstNmId">
                <div class="label">信审员</div>
                <div class="field">
                    <input name="auditorName" id="auditorName" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox col_33" id="searchInsCodeId">
             <div class="label">审批类型</div>
                   <div class="field">
                       <select name="schr6"  id="schr6" >
                         <option value="  " selected="selected">--请选择--</option>
                          <c:forEach items="${SCHR6List}" var="kv">
                         <option value="${kv.code}">${kv.codeNm}</option>
                        </c:forEach>
                      </select>
                   </div>
             </div>
             <div class="fieldBox col_33" id="cstMgrOrgCdId" >
			                <div class="label">所属公司</div>
			                <div class="field">
			                    <input name="cstMgrOrgCd" id="cstMgrOrgCd" type="text" class="ui-textbox" value="">
			                </div>
			</div>
            <%--<div class="fieldBox">
                <div class="label">所属区域</div>
                <div class="field">
                    <select name="cstMgrRgnCd"  id="cstMgrRgnCd" >
                        <option value="  " selected="selected">--请选择--</option>
                        <c:forEach items="${regionList}" var="opt">
                            <option value="${opt.key}">${opt.value}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>--%>
            <div class="clearFix"></div>
            <div class="btnsBox">
               <span id="searchBtn" class="sq-button sq-button-round">查询</span>
               <span id="clearBtn"  class="sq-button sq-button-round">清空</span>
            </div>
            </div>
        </form>
    </div>
</div>

<div id="ligergrid1" class="sq-grid"></div>


</body>
</html>